﻿<UserControl x:Class="SoftTeach.View.Termine.SchulterminWorkspaceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:termineView="clr-namespace:SoftTeach.View.Termine" 
             xmlns:termineViewModel="clr-namespace:SoftTeach.ViewModel.Termine" 
             xmlns:softTeach="clr-namespace:SoftTeach"
             xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="900">
  <UserControl.Resources>
  </UserControl.Resources>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="350"/>
      <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="0">
      <Border Grid.Row="1" CornerRadius="10" Margin="5" Padding="5,5,10,5" >
        <Grid >
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
          </Grid.RowDefinitions>
          <Label Grid.Row="0" Content="Vorhandene Termine" HorizontalContentAlignment="Center" FontSize="18"/>
          
          <GroupBox Grid.Row="1" Header="Filtern" Margin="0,0,0,5">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="60"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
              </Grid.ColumnDefinitions>
              <Label Grid.Row="0" Grid.Column="0" Padding="3" VerticalAlignment="Center">Schuljahr</Label>
              <ComboBox Grid.Row="0" Grid.Column="1" MinWidth="120" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Jahrtypen}"
                              SelectedValue="{Binding Path=JahrtypFilter}" 
                              SelectedValuePath="." 
                              DisplayMemberPath="JahrtypBezeichnung"
                        Style="{StaticResource DatagridComboBoxElementStyle}"/>
              <Button Grid.Row="0" Grid.Column="2" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                Command="{Binding Path=ResetJahrtypFilterCommand}">
                <Image Source="/SoftTeach;component/Images/Remove16.png"/>
              </Button>
              <Label Grid.Row="1" Grid.Column="0" Padding="3" VerticalAlignment="Center">Typ</Label>
              <ComboBox Grid.Row="1" Grid.Column="1" MinWidth="120" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Termintypen}"
                              SelectedValue="{Binding Path=TermintypFilter}" 
                              SelectedValuePath="." 
                              DisplayMemberPath="TermintypBezeichnung"
                        Style="{StaticResource DatagridComboBoxElementStyle}"/>
              <Button Grid.Row="1" Grid.Column="2" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                Command="{Binding Path=ResetTermintypFilterCommand}">
                <Image Source="/SoftTeach;component/Images/Remove16.png"/>
              </Button>
            </Grid>
          </GroupBox>
          <DataGrid Grid.Row="2" SelectedItem="{Binding Path=CurrentTermin, Mode=TwoWay}" ItemsSource="{Binding Path=TermineView}" AutoGenerateColumns="False" >
            <DataGrid.Columns>
              <DataGridTextColumn Header="Datum" Binding="{Binding Path=SchulterminDatum, StringFormat={}{0:dd.MM.yy},ConverterCulture={x:Static globalization:CultureInfo.CurrentCulture}}"
                                  SortMemberPath="SchulterminDatum"/>
              <DataGridComboBoxColumn 
                        Header="Typ" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Termintypen}"
                        SelectedItemBinding="{Binding Path=TerminTermintyp}" 
                        DisplayMemberPath="TermintypBezeichnung"
                SortMemberPath="TerminTermintyp.TermintypBezeichnung"
                EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
              <DataGridTextColumn Header="Beschreibung" Binding="{Binding Path=TerminBeschreibung}"
                                  SortMemberPath="TerminBeschreibung" Width="*"/>
              <DataGridTemplateColumn CanUserReorder="False" IsReadOnly="False">
                <DataGridTemplateColumn.CellTemplate>
                  <DataTemplate>
                    <Button Command="{Binding Path=DeleteTerminCommand}">
                      <Grid>
                        <Image Source="/SoftTeach;component/Images/Schultermin16.png" />
                        <Image Source="/SoftTeach;component/Images/RemoveOverlay16.png"/>
                      </Grid>
                    </Button>
                  </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
              </DataGridTemplateColumn>
            </DataGrid.Columns>
          </DataGrid>
        </Grid>
      </Border>
    </Grid>
    <Grid Grid.Column="1">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <StackPanel Grid.Row="0" Orientation="Horizontal">
        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddTerminCommand}" ToolTip="Neuen Termin erstellen">
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Schultermin32.png"/>
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Termin anlegen</Label>
          </StackPanel>
        </Button>
        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddMultipleDayTerminCommand}" ToolTip="Mehrtägigen Termin anlegen" >
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Schultermin32.png" />
              <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Mehrtägigen Termin anlegen</Label>
          </StackPanel>
        </Button>
        <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=DeleteTerminCommand}" ToolTip="Termin löschen" >
          <StackPanel Orientation="Horizontal">
            <Grid>
              <Image Source="/SoftTeach;component/Images/Schultermin32.png" />
              <Image Source="/SoftTeach;component/Images/RemoveOverlay32.png"/>
            </Grid>
            <Label Padding="5,0,0,0" VerticalContentAlignment="Center">Aktuellen Termin löschen</Label>
          </StackPanel>
        </Button>
      </StackPanel>
      <ContentControl Grid.Row="1" Content="{Binding Path=CurrentTermin}">
        <ContentControl.Resources>
          <DataTemplate DataType="{x:Type termineViewModel:SchulterminViewModel}">
            <termineView:SchulterminDetailView />
          </DataTemplate>
        </ContentControl.Resources>
      </ContentControl>
    </Grid>
  </Grid>
</UserControl>
